SBC Site Name Script

The M365 default onboarding script using SBC Site name is shown below. This script is hard-coded and is not included in the SQL database. The script is identical to the Default M365 Tenant Onboarding Script and in addition adds the SBC Site Name to the 'Unrestricted' entry for the Voice Routing Policy and Pstn Usage records. The Site Name is derived by default from the Customer shortname.

Copy
# Begin of Microsoft onboarding script
    # Add PSTN Usage record Unrestricted-{{SBC.sbcSiteName}} if not exists
    if(Get-CsOnlinePstnUsage | Where-Object Usage -NotContains "Unrestricted-{{SBC.sbcSiteName}}"
        {
            Set-CsOnlinePstnUsage -Identity Global -Usage @{Add="Unrestricted-{{SBC.sbcSiteName}}"};
        }

    # Add Online Voice Route Unrestricted-{{SBC.sbcSiteName}} if not exists, else add additional PSTN Gateway to the OnlinePstnGatewayList if there is a new PSTN Gateway
    
    if(Get-CsOnlineVoiceRoute | Where-Object {$_.Identity -eq "Unrestricted-{{SBC.sbcSiteName}}"})
        {
            Write-host "The CsOnlineVoiceRoute named Unrestricted-{{SBC.sbcSiteName}} already exists."
            if(Get-CsOnlineVoiceRoute -Identity "Unrestricted-{{SBC.sbcSiteName}}" | Where-Object {$_.OnlinePstnGatewayList -NotContains "{{SBC.OnlinePstnGateway}}"})
            {
                Write-host "A new PSTN Gateway is added to the the OnlinePstnGatewayList."
                Set-CsOnlineVoiceRoute -Identity "Unrestricted-{{SBC.sbcSiteName}}" -OnlinePstnGatewayList  @{add="{{SBC.OnlinePstnGateway}}"}
            }
        }else {
            Write-host "The CsOnlineVoiceRoute named Unrestricted-{{SBC.sbcSiteName}} does not exist, creating one."
            New-CsOnlineVoiceRoute -Identity "Unrestricted-{{SBC.sbcSiteName}}" -NumberPattern ".*" -OnlinePstnGatewayList @{add="{{SBC.OnlinePstnGateway}}"} -Priority 1 -OnlinePstnUsages @{add="Unrestricted-{{SBC.sbcSiteName}}"};
        }


    # Add Voice Routing Policy Unrestricted-{{SBC.sbcSiteName}} if not exists

    if(Get-CsOnlineVoiceRoutingPolicy | Where-Object {$_.Identity -like "Tag:Unrestricted-{{SBC.sbcSiteName}}"})
        {
        }else {
            New-CsOnlineVoiceRoutingPolicy -Identity "Unrestricted-{{SBC.sbcSiteName}}" -OnlinePstnUsages "Unrestricted-{{SBC.sbcSiteName}}";
        }
    # End of M365 onboarding script;